package com.zhongxi.guoyuan.OffLineShop;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.zhongxi.guoyuan.OffLineShop.Adapter.MentlistAdapter;
import com.zhongxi.guoyuan.OffLineShop.Model.PayMentList;
import com.zhongxi.guoyuan.OffLineShop.UI.MentDetailActivity;
import com.zhongxi.guoyuan.R;
import com.zhongxi.guoyuan.utils.UiUtils;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/4/12.
 */

public class MentListFragment extends OffLineBaseFragment {

    @Bind(R.id.recycleView)
    RecyclerView mRecycleView;
    private ArrayList<PayMentList.MentList> mData;

    @Override
    protected void initParams() {
        super.initParams();
        if (getArguments() != null) {
            mData = (ArrayList<PayMentList.MentList>) getArguments().getSerializable("mentList");
        }
    }

    @Override
    protected View init() {
        View mView = UiUtils.inflate(R.layout.fragment_mentlis);
        ButterKnife.bind(this, mView);
        return mView;
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        mRecycleView.setLayoutManager(new LinearLayoutManager(UiUtils.getContext()));
        MentlistAdapter adapter = new MentlistAdapter(mData);
        mRecycleView.setAdapter(adapter);
        adapter.setOnItemClickListener(new MentlistAdapter.OnItemClickListener() {
            @Override
            public void onItemClickListener(View view, int position) {
                Intent mIntent = new Intent(UiUtils.getContext(), MentDetailActivity.class);
                mIntent.putExtra("orderid", mData.get(position).id);
                startActivity(mIntent);
            }
        });
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
